#ifndef DATETIMEEDIT_H
#define DATETIMEEDIT_H

#include "utkwidget_export.h"

#include <QLineEdit>

class UDatetimeRangeEditPrivate;
class UTKWIDGET_EXPORT UDatetimeRangeEdit : public QLineEdit
{
    Q_OBJECT
public:
    enum LinePosition
    {
        Left,
        Right,
        None
    };

    explicit UDatetimeRangeEdit(QWidget* parent = nullptr);
    ~UDatetimeRangeEdit();

    void setLinePosition(LinePosition linePosition);

    void showCalendarWidget(LinePosition linePosition, const QPoint &point);

    void setStartDateTime(const QDateTime &dateTime);

    void setEndDateTime(const QDateTime &dateTime);

    QDateTime startDateTime() const;

    QDateTime endDateTime() const;

    void startTime();

    void stopTime();

    bool isActived() const;

protected:
    void paintEvent(QPaintEvent* event) override;

    bool eventFilter(QObject* obj, QEvent* event) override;

    QSize sizeHint() const override;

signals:
    void dateTimeChanged(const QPair<QDateTime, QDateTime> &time);

public slots:
    void onSelectDateTime(const QDateTime &time);

private:
    QScopedPointer<UDatetimeRangeEditPrivate> d_ptr;
    Q_DISABLE_COPY(UDatetimeRangeEdit)
    Q_DECLARE_PRIVATE_D(d_ptr, UDatetimeRangeEdit)
};

#endif // DATETIMEEDIT_H
